/*$(document).ready( 
    function() { 
      $(".add-cart a").click( 
          function() { 
        	//  alert("awdw");
        	  $.ajax({
        		  	type:"POST",
        	        url: 'time.html',
        	        data: ({name : "me"}),
        	        contentType: "application/json;charset=utf-8",
        	        dataType: "json",
        	        success: function(data) {
        	        	alert(data.name);
        	        },
        	        error: function(e){
        	        alert('Error: ' + e.responseText);
        	        }
        	      });
          }); 
    });*/
function doAjax(product_id) {
	$('.dropdown-1 li').remove(); 
	  $.ajax({
		  url: '/shopping-mall/addcart',
	      data:  ({productId : product_id}),
	      success: function(data) {	        		       	            	    	  
	    	  var items=data.items;	        	    	 	        	    	 	
	    	  for(var i = 0; i < items.length; i++){
	    		  var item = items[i];
	    		  var url="<a href='javascript:delItem("+i+")'> Delete</a>";
	    		  var newitem="<li>Product :"+item.name+" - Price :"+item.price+"Quantity :"+item.quantity+url+"</li>";
  	    	  $(newitem).appendTo('.dropdown-1');
  	    	//$(newitem).text('#quantity');
  	    	 
	    	  }	     
	    	  
	      }	        	      
	      });
	 			/*	$('.table table-bordered tr').remove(); 
	        	  $.ajax({
	        		  url: '/shopping-mall/addcart',
	        	      data:  ({productId : product_id}),
	        	      success: function(data) {	        		       	            	    	  
	        	    	  var items=data.items;	 
	        	    	  
	        	    	  for(var i = 0; i < items.length; i++){
	        	    		  var item = items[i];
	        	    		  var url="<a href='javascript:delItem("+i+")'> Delete</a>";
	        	    		  
	        	    		  var newitem="<tr>"+
								"<td>"+item.name+"</td>"+
								"<td>"+item.price+"</td>"+
								"<td>"+item.quantity+"</td>"+
								"<td>"+url+"Delete</a>"+
								"</td>"+
								"</tr>";
		        	    	  $(newitem).appendTo('.add-here');
	        	    	  }	        	    	
	        	      }	        	      
	        	      });*/
	   
  }
function delItem(product_id){
	// alert(product_id);
	$('.dropdown-1 li').remove(); 
	 $.ajax({
		  url: '/shopping-mall/delcart',
	      data:  ({productId : product_id}),
	      success: function(data) {	 
	    	  var items=data.items;
	    	  for(var i = 0; i < items.length; i++){
	    		  var item = items[i];
	    		  var url="<a href='javascript:delItem("+i+")'>"+" Delete</a>";
	    		  var newitem="<li> Product :"+item.name+" - Price :"+item.price+"Quantity :"+item.quantity+url+"</li>";
	    		  $(newitem).appendTo('.dropdown-1');
	    	  }	       	    	
	      }	       	      
	      });
}